package com.monkeyboy.second.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description
 * @Author Gavin
 * @date 2020.04.27 14:47
 */
public class FixedThreadPoolTest {
    public static void main(String[] args) {
        //该线程池是固定的线程数量，但是队列是无界队列，使用时候得注意队列任务过多导致oom情况，
        //存活时间没有，因为是固定的所以不需要考虑回收的情况
        ExecutorService executorService = Executors.newFixedThreadPool(4);
        for (int i = 0; i < 1000; i++) {
            executorService.execute(new Task());
            executorService.submit(new Task());
        }
    }
}
